﻿using UnityEngine;

[DisallowMultipleComponent]
public class NotifyPoint : MonoBehaviour
{
    public NotifyType type = NotifyType.None;
    public bool isShowTxt = false;
    public UILabel txtNum;
    
    private void Awake()
    {
        if (txtNum == null) { isShowTxt = false; }
        else
        {
            Utility.SetActive(txtNum, isShowTxt);
        }
        Utility.SetActive(gameObject, false);
        SetNotifyEvent(true, (int)type);
    }

    private void OnDestroy()
    {
        SetNotifyEvent(false, (int)type);
    }

    public void SetNotifyEvent(bool isAddRem, int nType)
    {
        if (nType != (int)NotifyType.None)
        {
            ZMgr.NotifyMgr.UPNotifyEvent(isAddRem, nType, UpView);
        }
    }

    private void UpView(NotifyVo notifyVo)
    {
        Utility.SetActive(gameObject, notifyVo.isShow);
        if (txtNum && isShowTxt)
        {
            txtNum.text = notifyVo.num.ToString();
            Utility.SetActive(txtNum, notifyVo.num > 0);
        }
    }
}